package com.navinfo.platform.etl.flink.custom;

import org.apache.flink.table.filesystem.PartitionTimeExtractor;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * 分区时间提取器，解决差8小的问题
 */
public class HourPartTimeExtractor implements PartitionTimeExtractor {

	@Override
	public LocalDateTime extract(List<String> keys, List<String> values) {

		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss");
		String dateStr = values.get(0)+" "+values.get(1)+":00:00";

		//转换成UTF时间
		return LocalDateTime.parse(dateStr, dateTimeFormatter).minusHours(8);
	}
}